import { ColorString, LaunchOptions } from "@sfx-lib/core";
/**
 * 检查启动选项配置并返回一个 LaunchOptions 实体
 */
function checkLaunchOptions(options: LaunchOptions) {
    //
    let result = options;

    // 定义一个本地选项
    // 1. 区分不同项目的偏好设置
    // 2. 存储数据的key前缀
    // 3. 其他一些需要隔离的数据
    const suffix = "workspace";
    const appTitle = import.meta.env.VITE_APP_TITLE;
    const appVersion = import.meta.env.VITE_APP_VERSION;
    const workspace = `${appTitle}-${appVersion}-${suffix}`;
    const localOptions: LaunchOptions = {
        workspace: workspace,
    };

    if (!options) {
        result = Object.assign({}, localOptions);
    } else if (!options.workspace) {
        result = Object.assign({}, options, localOptions);
    } else {
        result = options;
    }

    // console.log(result);
    // console.log(ColorString.Blue(result.workspace!));

    return result;
}

async function unmount() {
    // console.log("unmount...")
}

export { checkLaunchOptions, unmount };
